home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JTable$AccessibleJTable.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  10.3 KB  |  514 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Point;
  4. import java.beans.PropertyChangeEvent;
  5. import java.beans.PropertyChangeListener;
  6. import javax.accessibility.Accessible;
  7. import javax.accessibility.AccessibleExtendedTable;
  8. import javax.accessibility.AccessibleRole;
  9. import javax.accessibility.AccessibleSelection;
  10. import javax.accessibility.AccessibleTable;
  11. import javax.swing.event.CellEditorListener;
  12. import javax.swing.event.ChangeEvent;
  13. import javax.swing.event.ListSelectionEvent;
  14. import javax.swing.event.ListSelectionListener;
  15. import javax.swing.event.TableColumnModelEvent;
  16. import javax.swing.event.TableColumnModelListener;
  17. import javax.swing.event.TableModelEvent;
  18. import javax.swing.event.TableModelListener;
  19. import javax.swing.table.JTableHeader;
  20. import javax.swing.table.TableCellEditor;
  21. import javax.swing.table.TableCellRenderer;
  22. import javax.swing.table.TableColumn;
  23. import javax.swing.table.TableColumnModel;
  24. import javax.swing.table.TableModel;
  25.  
  26. public class JTable$AccessibleJTable extends JComponent.AccessibleJComponent implements AccessibleSelection, ListSelectionListener, TableModelListener, TableColumnModelListener, CellEditorListener, PropertyChangeListener, AccessibleExtendedTable {
  27.    int lastSelectedRow;
  28.    int lastSelectedCol;
  29.    private Accessible caption;
  30.    private Accessible summary;
  31.    private Accessible[] rowDescription;
  32.    private Accessible[] columnDescription;
  33.    // $FF: synthetic field
  34.    final JTable this$0;
  35.  
  36.    protected JTable$AccessibleJTable(JTable var1) {
  37.       super(var1);
  38.       this.this$0 = var1;
  39.       var1.addPropertyChangeListener(this);
  40.       var1.getSelectionModel().addListSelectionListener(this);
  41.       TableColumnModel var2 = var1.getColumnModel();
  42.       var2.addColumnModelListener(this);
  43.       var2.getSelectionModel().addListSelectionListener(this);
  44.       var1.getModel().addTableModelListener(this);
  45.       this.lastSelectedRow = var1.getSelectedRow();
  46.       this.lastSelectedCol = var1.getSelectedColumn();
  47.    }
  48.  
  49.    public void propertyChange(PropertyChangeEvent var1) {
  50.       String var2 = var1.getPropertyName();
  51.       Object var3 = var1.getOldValue();
  52.       Object var4 = var1.getNewValue();
  53.       if (var2.compareTo("model") == 0) {
  54.          if (var3 != null && var3 instanceof TableModel) {
  55.             ((TableModel)var3).removeTableModelListener(this);
  56.          }
  57.  
  58.          if (var4 != null && var4 instanceof TableModel) {
  59.             ((TableModel)var4).addTableModelListener(this);
  60.          }
  61.       } else if (var2.compareTo("selectionModel") == 0) {
  62.          Object var5 = var1.getSource();
  63.          if (var5 == this.this$0) {
  64.             if (var3 != null && var3 instanceof ListSelectionModel) {
  65.                ((ListSelectionModel)var3).removeListSelectionListener(this);
  66.             }
  67.  
  68.             if (var4 != null && var4 instanceof ListSelectionModel) {
  69.                ((ListSelectionModel)var4).addListSelectionListener(this);
  70.             }
  71.          } else if (var5 == this.this$0.getColumnModel()) {
  72.             if (var3 != null && var3 instanceof ListSelectionModel) {
  73.                ((ListSelectionModel)var3).removeListSelectionListener(this);
  74.             }
  75.  
  76.             if (var4 != null && var4 instanceof ListSelectionModel) {
  77.                ((ListSelectionModel)var4).addListSelectionListener(this);
  78.             }
  79.          }
  80.       } else if (var2.compareTo("columnModel") == 0) {
  81.          if (var3 != null && var3 instanceof TableColumnModel) {
  82.             TableColumnModel var6 = (TableColumnModel)var3;
  83.             var6.removeColumnModelListener(this);
  84.             var6.getSelectionModel().removeListSelectionListener(this);
  85.          }
  86.  
  87.          if (var4 != null && var4 instanceof TableColumnModel) {
  88.             TableColumnModel var7 = (TableColumnModel)var4;
  89.             var7.addColumnModelListener(this);
  90.             var7.getSelectionModel().addListSelectionListener(this);
  91.          }
  92.       } else if (var2.compareTo("tableCellEditor") == 0) {
  93.          if (var3 != null && var3 instanceof TableCellEditor) {
  94.             ((TableCellEditor)var3).removeCellEditorListener(this);
  95.          }
  96.  
  97.          if (var4 != null && var4 instanceof TableCellEditor) {
  98.             ((TableCellEditor)var4).addCellEditorListener(this);
  99.          }
  100.       }
  101.  
  102.    }
  103.  
  104.    public void tableChanged(TableModelEvent var1) {
  105.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  106.       if (var1 != null) {
  107.          int var2 = var1.getColumn();
  108.          int var3 = var1.getColumn();
  109.          if (var2 == -1) {
  110.             var2 = 0;
  111.             var3 = this.this$0.getColumnCount() - 1;
  112.          }
  113.  
  114.          JTable.AccessibleJTable.AccessibleJTableModelChange var4 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var1.getType(), var1.getFirstRow(), var1.getLastRow(), var2, var3);
  115.          this.firePropertyChange("accessibleTableModelChanged", (Object)null, var4);
  116.       }
  117.  
  118.    }
  119.  
  120.    public void tableRowsInserted(TableModelEvent var1) {
  121.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  122.       int var2 = var1.getColumn();
  123.       int var3 = var1.getColumn();
  124.       if (var2 == -1) {
  125.          var2 = 0;
  126.          var3 = this.this$0.getColumnCount() - 1;
  127.       }
  128.  
  129.       JTable.AccessibleJTable.AccessibleJTableModelChange var4 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var1.getType(), var1.getFirstRow(), var1.getLastRow(), var2, var3);
  130.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var4);
  131.    }
  132.  
  133.    public void tableRowsDeleted(TableModelEvent var1) {
  134.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  135.       int var2 = var1.getColumn();
  136.       int var3 = var1.getColumn();
  137.       if (var2 == -1) {
  138.          var2 = 0;
  139.          var3 = this.this$0.getColumnCount() - 1;
  140.       }
  141.  
  142.       JTable.AccessibleJTable.AccessibleJTableModelChange var4 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var1.getType(), var1.getFirstRow(), var1.getLastRow(), var2, var3);
  143.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var4);
  144.    }
  145.  
  146.    public void columnAdded(TableColumnModelEvent var1) {
  147.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  148.       byte var2 = 1;
  149.       JTable.AccessibleJTable.AccessibleJTableModelChange var3 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var2, 0, 0, var1.getFromIndex(), var1.getToIndex());
  150.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var3);
  151.    }
  152.  
  153.    public void columnRemoved(TableColumnModelEvent var1) {
  154.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  155.       byte var2 = -1;
  156.       JTable.AccessibleJTable.AccessibleJTableModelChange var3 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var2, 0, 0, var1.getFromIndex(), var1.getToIndex());
  157.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var3);
  158.    }
  159.  
  160.    public void columnMoved(TableColumnModelEvent var1) {
  161.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  162.       byte var2 = -1;
  163.       JTable.AccessibleJTable.AccessibleJTableModelChange var3 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var2, 0, 0, var1.getFromIndex(), var1.getFromIndex());
  164.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var3);
  165.       byte var4 = 1;
  166.       JTable.AccessibleJTable.AccessibleJTableModelChange var5 = new JTable.AccessibleJTable.AccessibleJTableModelChange(this, var4, 0, 0, var1.getToIndex(), var1.getToIndex());
  167.       this.firePropertyChange("accessibleTableModelChanged", (Object)null, var5);
  168.    }
  169.  
  170.    public void columnMarginChanged(ChangeEvent var1) {
  171.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  172.    }
  173.  
  174.    public void columnSelectionChanged(ListSelectionEvent var1) {
  175.    }
  176.  
  177.    public void editingStopped(ChangeEvent var1) {
  178.       this.firePropertyChange("AccessibleVisibleData", (Object)null, (Object)null);
  179.    }
  180.  
  181.    public void editingCanceled(ChangeEvent var1) {
  182.    }
  183.  
  184.    public void valueChanged(ListSelectionEvent var1) {
  185.       this.firePropertyChange("AccessibleSelection", false, true);
  186.       int var2 = this.this$0.getSelectedRow();
  187.       int var3 = this.this$0.getSelectedColumn();
  188.       if (var2 != this.lastSelectedRow || var3 != this.lastSelectedCol) {
  189.          Accessible var4 = this.getAccessibleAt(this.lastSelectedRow, this.lastSelectedCol);
  190.          Accessible var5 = this.getAccessibleAt(var2, var3);
  191.          this.firePropertyChange("AccessibleActiveDescendant", var4, var5);
  192.          this.lastSelectedRow = var2;
  193.          this.lastSelectedCol = var3;
  194.       }
  195.  
  196.    }
  197.  
  198.    public AccessibleSelection getAccessibleSelection() {
  199.       return this;
  200.    }
  201.  
  202.    public AccessibleRole getAccessibleRole() {
  203.       return AccessibleRole.TABLE;
  204.    }
  205.  
  206.    public Accessible getAccessibleAt(Point var1) {
  207.       int var2 = this.this$0.columnAtPoint(var1);
  208.       int var3 = this.this$0.rowAtPoint(var1);
  209.       if (var2 != -1 && var3 != -1) {
  210.          TableColumn var4 = this.this$0.getColumnModel().getColumn(var2);
  211.          TableCellRenderer var5 = var4.getCellRenderer();
  212.          if (var5 == null) {
  213.             Class var6 = this.this$0.getColumnClass(var2);
  214.             var5 = this.this$0.getDefaultRenderer(var6);
  215.          }
  216.  
  217.          var5.getTableCellRendererComponent(this.this$0, (Object)null, false, false, var3, var2);
  218.          return new JTable.AccessibleJTable.AccessibleJTableCell(this, this.this$0, var3, var2, this.getAccessibleIndexAt(var3, var2));
  219.       } else {
  220.          return null;
  221.       }
  222.    }
  223.  
  224.    public int getAccessibleChildrenCount() {
  225.       return this.this$0.getColumnCount() * this.this$0.getRowCount();
  226.    }
  227.  
  228.    public Accessible getAccessibleChild(int var1) {
  229.       if (var1 >= 0 && var1 < this.getAccessibleChildrenCount()) {
  230.          int var2 = this.getAccessibleColumnAtIndex(var1);
  231.          int var3 = this.getAccessibleRowAtIndex(var1);
  232.          TableColumn var4 = this.this$0.getColumnModel().getColumn(var2);
  233.          TableCellRenderer var5 = var4.getCellRenderer();
  234.          if (var5 == null) {
  235.             Class var6 = this.this$0.getColumnClass(var2);
  236.             var5 = this.this$0.getDefaultRenderer(var6);
  237.          }
  238.  
  239.          var5.getTableCellRendererComponent(this.this$0, (Object)null, false, false, var3, var2);
  240.          return new JTable.AccessibleJTable.AccessibleJTableCell(this, this.this$0, var3, var2, this.getAccessibleIndexAt(var3, var2));
  241.       } else {
  242.          return null;
  243.       }
  244.    }
  245.  
  246.    public int getAccessibleSelectionCount() {
  247.       int var1 = this.this$0.getSelectedRowCount();
  248.       int var2 = this.this$0.getSelectedColumnCount();
  249.       if (this.this$0.cellSelectionEnabled) {
  250.          return var1 * var2;
  251.       } else if (this.this$0.getRowSelectionAllowed() && this.this$0.getColumnSelectionAllowed()) {
  252.          return var1 * this.this$0.getColumnCount() + var2 * this.this$0.getRowCount() - var1 * var2;
  253.       } else if (this.this$0.getRowSelectionAllowed()) {
  254.          return var1 * this.this$0.getColumnCount();
  255.       } else {
  256.          return this.this$0.getColumnSelectionAllowed() ? var2 * this.this$0.getRowCount() : 0;
  257.       }
  258.    }
  259.  
  260.    public Accessible getAccessibleSelection(int var1) {
  261.       if (var1 >= 0 && var1 <= this.getAccessibleSelectionCount()) {
  262.          int var2 = this.this$0.getSelectedRowCount();
  263.          int var3 = this.this$0.getSelectedColumnCount();
  264.          int[] var4 = this.this$0.getSelectedRows();
  265.          int[] var5 = this.this$0.getSelectedColumns();
  266.          int var6 = this.this$0.getColumnCount();
  267.          int var7 = this.this$0.getRowCount();
  268.          if (this.this$0.cellSelectionEnabled) {
  269.             int var20 = var4[var1 / var3];
  270.             int var25 = var5[var1 % var3];
  271.             return this.getAccessibleChild(var20 * var6 + var25);
  272.          } else {
  273.             if (this.this$0.getRowSelectionAllowed() && this.this$0.getColumnSelectionAllowed()) {
  274.                int var10 = var1;
  275.                int var13 = var4[0] == 0 ? 0 : 1;
  276.                int var14 = 0;
  277.                int var15 = -1;
  278.  
  279.                while(var14 < var4.length) {
  280.                   switch (var13) {
  281.                      case 0:
  282.                         if (var10 < var6) {
  283.                            int var23 = var10 % var6;
  284.                            int var18 = var4[var14];
  285.                            return this.getAccessibleChild(var18 * var6 + var23);
  286.                         }
  287.  
  288.                         var10 -= var6;
  289.                         if (var14 + 1 == var4.length || var4[var14] != var4[var14 + 1] - 1) {
  290.                            var13 = 1;
  291.                            var15 = var4[var14];
  292.                         }
  293.  
  294.                         ++var14;
  295.                         break;
  296.                      case 1:
  297.                         if (var10 < var3 * (var4[var14] - (var15 == -1 ? 0 : var15 + 1))) {
  298.                            int var22 = var5[var10 % var3];
  299.                            int var17 = (var14 > 0 ? var4[var14 - 1] + 1 : 0) + var10 / var3;
  300.                            return this.getAccessibleChild(var17 * var6 + var22);
  301.                         }
  302.  
  303.                         var10 -= var3 * (var4[var14] - (var15 == -1 ? 0 : var15 + 1));
  304.                         var13 = 0;
  305.                   }
  306.                }
  307.  
  308.                if (var10 < var3 * (var7 - (var15 == -1 ? 0 : var15 + 1))) {
  309.                   int var24 = var5[var10 % var3];
  310.                   int var19 = var4[var14 - 1] + var10 / var3 + 1;
  311.                   return this.getAccessibleChild(var19 * var6 + var24);
  312.                }
  313.             } else {
  314.                if (this.this$0.getRowSelectionAllowed()) {
  315.                   int var21 = var1 % var6;
  316.                   int var16 = var4[var1 / var6];
  317.                   return this.getAccessibleChild(var16 * var6 + var21);
  318.                }
  319.  
  320.                if (this.this$0.getColumnSelectionAllowed()) {
  321.                   int var9 = var5[var1 % var3];
  322.                   int var8 = var1 / var3;
  323.                   return this.getAccessibleChild(var8 * var6 + var9);
  324.                }
  325.             }
  326.  
  327.             return (Accessible)null;
  328.          }
  329.       } else {
  330.          return (Accessible)null;
  331.       }
  332.    }
  333.  
  334.    public boolean isAccessibleChildSelected(int var1) {
  335.       int var2 = this.getAccessibleColumnAtIndex(var1);
  336.       int var3 = this.getAccessibleRowAtIndex(var1);
  337.       return this.this$0.isCellSelected(var3, var2);
  338.    }
  339.  
  340.    public void addAccessibleSelection(int var1) {
  341.       int var2 = this.getAccessibleColumnAtIndex(var1);
  342.       int var3 = this.getAccessibleRowAtIndex(var1);
  343.       this.this$0.changeSelection(var3, var2, true, false);
  344.    }
  345.  
  346.    public void removeAccessibleSelection(int var1) {
  347.       if (this.this$0.cellSelectionEnabled) {
  348.          int var2 = this.getAccessibleColumnAtIndex(var1);
  349.          int var3 = this.getAccessibleRowAtIndex(var1);
  350.          this.this$0.removeRowSelectionInterval(var3, var3);
  351.          this.this$0.removeColumnSelectionInterval(var2, var2);
  352.       }
  353.  
  354.    }
  355.  
  356.    public void clearAccessibleSelection() {
  357.       this.this$0.clearSelection();
  358.    }
  359.  
  360.    public void selectAllAccessibleSelection() {
  361.       if (this.this$0.cellSelectionEnabled) {
  362.          this.this$0.selectAll();
  363.       }
  364.  
  365.    }
  366.  
  367.    public int getAccessibleRow(int var1) {
  368.       return this.getAccessibleRowAtIndex(var1);
  369.    }
  370.  
  371.    public int getAccessibleColumn(int var1) {
  372.       return this.getAccessibleColumnAtIndex(var1);
  373.    }
  374.  
  375.    public int getAccessibleIndex(int var1, int var2) {
  376.       return this.getAccessibleIndexAt(var1, var2);
  377.    }
  378.  
  379.    public AccessibleTable getAccessibleTable() {
  380.       return this;
  381.    }
  382.  
  383.    public Accessible getAccessibleCaption() {
  384.       return this.caption;
  385.    }
  386.  
  387.    public void setAccessibleCaption(Accessible var1) {
  388.       Accessible var2 = this.caption;
  389.       this.caption = var1;
  390.       this.firePropertyChange("accessibleTableCaptionChanged", var2, this.caption);
  391.    }
  392.  
  393.    public Accessible getAccessibleSummary() {
  394.       return this.summary;
  395.    }
  396.  
  397.    public void setAccessibleSummary(Accessible var1) {
  398.       Accessible var2 = this.summary;
  399.       this.summary = var1;
  400.       this.firePropertyChange("accessibleTableSummaryChanged", var2, this.summary);
  401.    }
  402.  
  403.    public int getAccessibleRowCount() {
  404.       return this.this$0.getRowCount();
  405.    }
  406.  
  407.    public int getAccessibleColumnCount() {
  408.       return this.this$0.getColumnCount();
  409.    }
  410.  
  411.    public Accessible getAccessibleAt(int var1, int var2) {
  412.       return this.getAccessibleChild(var1 * this.getAccessibleColumnCount() + var2);
  413.    }
  414.  
  415.    public int getAccessibleRowExtentAt(int var1, int var2) {
  416.       return 1;
  417.    }
  418.  
  419.    public int getAccessibleColumnExtentAt(int var1, int var2) {
  420.       return 1;
  421.    }
  422.  
  423.    public AccessibleTable getAccessibleRowHeader() {
  424.       return null;
  425.    }
  426.  
  427.    public void setAccessibleRowHeader(AccessibleTable var1) {
  428.    }
  429.  
  430.    public AccessibleTable getAccessibleColumnHeader() {
  431.       JTableHeader var1 = this.this$0.getTableHeader();
  432.       return var1 == null ? null : new JTable.AccessibleJTable.AccessibleTableHeader(this, var1);
  433.    }
  434.  
  435.    public void setAccessibleColumnHeader(AccessibleTable var1) {
  436.    }
  437.  
  438.    public Accessible getAccessibleRowDescription(int var1) {
  439.       if (var1 >= 0 && var1 < this.getAccessibleRowCount()) {
  440.          return this.rowDescription == null ? null : this.rowDescription[var1];
  441.       } else {
  442.          throw new IllegalArgumentException((new Integer(var1)).toString());
  443.       }
  444.    }
  445.  
  446.    public void setAccessibleRowDescription(int var1, Accessible var2) {
  447.       if (var1 >= 0 && var1 < this.getAccessibleRowCount()) {
  448.          if (this.rowDescription == null) {
  449.             int var3 = this.getAccessibleRowCount();
  450.             this.rowDescription = new Accessible[var3];
  451.          }
  452.  
  453.          this.rowDescription[var1] = var2;
  454.       } else {
  455.          throw new IllegalArgumentException((new Integer(var1)).toString());
  456.       }
  457.    }
  458.  
  459.    public Accessible getAccessibleColumnDescription(int var1) {
  460.       if (var1 >= 0 && var1 < this.getAccessibleColumnCount()) {
  461.          return this.columnDescription == null ? null : this.columnDescription[var1];
  462.       } else {
  463.          throw new IllegalArgumentException((new Integer(var1)).toString());
  464.       }
  465.    }
  466.  
  467.    public void setAccessibleColumnDescription(int var1, Accessible var2) {
  468.       if (var1 >= 0 && var1 < this.getAccessibleColumnCount()) {
  469.          if (this.columnDescription == null) {
  470.             int var3 = this.getAccessibleColumnCount();
  471.             this.columnDescription = new Accessible[var3];
  472.          }
  473.  
  474.          this.columnDescription[var1] = var2;
  475.       } else {
  476.          throw new IllegalArgumentException((new Integer(var1)).toString());
  477.       }
  478.    }
  479.  
  480.    public boolean isAccessibleSelected(int var1, int var2) {
  481.       return this.this$0.isCellSelected(var1, var2);
  482.    }
  483.  
  484.    public boolean isAccessibleRowSelected(int var1) {
  485.       return this.this$0.isRowSelected(var1);
  486.    }
  487.  
  488.    public boolean isAccessibleColumnSelected(int var1) {
  489.       return this.this$0.isColumnSelected(var1);
  490.    }
  491.  
  492.    public int[] getSelectedAccessibleRows() {
  493.       return this.this$0.getSelectedRows();
  494.    }
  495.  
  496.    public int[] getSelectedAccessibleColumns() {
  497.       return this.this$0.getSelectedColumns();
  498.    }
  499.  
  500.    public int getAccessibleRowAtIndex(int var1) {
  501.       int var2 = this.getAccessibleColumnCount();
  502.       return var2 == 0 ? -1 : var1 / var2;
  503.    }
  504.  
  505.    public int getAccessibleColumnAtIndex(int var1) {
  506.       int var2 = this.getAccessibleColumnCount();
  507.       return var2 == 0 ? -1 : var1 % var2;
  508.    }
  509.  
  510.    public int getAccessibleIndexAt(int var1, int var2) {
  511.       return var1 * this.getAccessibleColumnCount() + var2;
  512.    }
  513. }
  514.